import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import services.BookServices;

/**
 * Created by IntelliJ IDEA.
 * User: adminx
 * Date: 14.08.12
 * Time: 11:41
 * To change this template use File | Settings | File Templates.
 */
public class testAdd {
    @Test
    public void testAdd() throws Exception {
        boolean tableExist = false;
        ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/Bean.xml");
        BookServices bookServices = (BookServices) context.getBean("bookServices");
        try{
            bookServices.createBook("test3", "test4", "test4", "test4");
        }catch (Exception e){
             tableExist=true;
        }
        if(tableExist){
            bookServices.createTable();
        bookServices.createBook("test3", "test4", "test4", "test4");
        }
    }

    @Test
    public void testDelete(){
        ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/Bean.xml");
        BookServices bookServices = (BookServices) context.getBean("bookServices");

        bookServices.deleteBook(1);
    }
}
